<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
    同步回调
    异步回调
    */

    /* 同步回调 */

    [1, 2, 3].forEach(item => {
      console.log(item)
    })
    console.log('forEach()之后')

    new Promise((resolve, reject) => { // 执行器 / excutor
      console.log('excutor')
      // 执行异步操作, 比如 发ajax请求

      // 如果成功了, 调用resolve(value)

      // 如果失败了, 调用reject(reason)

    })
    console.log('new Promise之后')




    /* 异步回调  需要放到对应的队列中, 再取出执行 */
    setTimeout(() => { 
      console.log('执行timout回调')
    }, 0)
    console.log('setTimeout()之后')

    Promise.resolve(1).then(() => {// 异步回调
      console.log('promise成功的回调')
    })
    console.log('.then之后')
  </script>

</body>
</html>